import { createStore } from 'vuex'

// 创建一个新的 store 实例
const store = createStore({
    state () {
        return {
            cart: [],
            editingAddress : {},
            selectedAddress: null
        }
    },
    mutations: {
        setCart(state, goodsList){
            state.cart = goodsList
        },
        clearCart(state){
            state.cart = []
        },
        setEditingAddress(state, address){
            state.editingAddress = address
        },
        clearEditingAddress(state){
            state.editingAddress = {}
        },
        setSelectedAddress(state, address){
            state.selectedAddress = address;
        },
        clearSelectedAddress(state){
            state.selectedAddress = null;
        }
    },
    getters:{

    }
})

// 将 store 实例作为插件安装
export default store
